﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModels="clr-namespace:ScrumSprintMonitor.Modules.WorkItemMonitor.ViewModels"
    xmlns:Controls="clr-namespace:ScrumSprintMonitor.Modules.WorkItemMonitor.Controls"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="TeamMemberBadgeDataTemplate.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <DataTemplate DataType="{x:Type ViewModels:TeamMembersListViewModel}">
        <ScrollViewer VerticalScrollBarVisibility="Disabled">
            <ScrollViewer.OpacityMask>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF000000" Offset="0.942"/>
                    <GradientStop Color="#00FFFFFF" Offset="0.987"/>
                </LinearGradientBrush>
            </ScrollViewer.OpacityMask>

            <Grid Width="7cm" HorizontalAlignment="Center">
                <Controls:SprintWarningBorder>
                    <Controls:SprintWarningBorder.OpacityMask>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#00000000" Offset="0.0"/>
                            <GradientStop Color="#FF000000" Offset="0.3"/>
                            <GradientStop Color="#FF000000" Offset="1"/>
                        </LinearGradientBrush>
                    </Controls:SprintWarningBorder.OpacityMask>
                </Controls:SprintWarningBorder>

                <ScrollViewer>
                    <ScrollViewer.Resources>
                        <Style TargetType="{x:Type ScrollBar}">
                            <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ScrollBar}">
                                        <Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Background="Transparent">
                                            <Grid.RowDefinitions>
                                                <RowDefinition MaxHeight="18" />
                                                <RowDefinition Height="0.00001*" />
                                                <RowDefinition MaxHeight="18" />
                                            </Grid.RowDefinitions>
                                            <RepeatButton x:Name="DecreaseRepeat" Command="ScrollBar.LineUpCommand" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}">
                                                <Grid Margin="0,0,0,0">
                                                    <Path Margin="4.742,3.997,4.946,5.327" VerticalAlignment="Stretch" Height="Auto" Fill="{DynamicResource GlyphBrush}" Stretch="Fill" Stroke="{DynamicResource GlyphBrush}" StrokeThickness="1" Data="M5.2422477,11.132184 L11.5544,11.132184 8.6412958,4.4969033 z" x:Name="DecreaseArrow" />
                                                </Grid>
                                            </RepeatButton>
                                            <Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true">
                                                <Track.Thumb>
                                                    <Thumb Style="{DynamicResource NuclearThumbStyle}" Background="{x:Null}" Foreground="{x:Null}" />
                                                </Track.Thumb>
                                                <Track.IncreaseRepeatButton>
                                                    <RepeatButton x:Name="PageUp" Style="{DynamicResource NuclearScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand" />
                                                </Track.IncreaseRepeatButton>
                                                <Track.DecreaseRepeatButton>
                                                    <RepeatButton x:Name="PageDown" Style="{DynamicResource NuclearScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand" />
                                                </Track.DecreaseRepeatButton>
                                            </Track>
                                            <RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Command="ScrollBar.LineDownCommand">
                                                <Grid>
                                                    <Path Margin="4.742,3.997,4.946,5.327" x:Name="IncreaseArrow" VerticalAlignment="Stretch" Height="Auto" Fill="{DynamicResource GlyphBrush}" Stretch="Fill" Stroke="{DynamicResource GlyphBrush}" StrokeThickness="1" Data="M5.2422477,11.132184 L11.5544,11.132184 8.6412958,4.4969033 z" RenderTransformOrigin="0.5,0.5">
                                                        <Path.RenderTransform>
                                                            <TransformGroup>
                                                                <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                <SkewTransform AngleX="0" AngleY="0" />
                                                                <RotateTransform Angle="180" />
                                                                <TranslateTransform X="0" Y="0" />
                                                            </TransformGroup>
                                                        </Path.RenderTransform>
                                                    </Path>
                                                </Grid>
                                            </RepeatButton>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="Orientation" Value="Horizontal">
                                                <Setter Property="LayoutTransform" TargetName="GridRoot">
                                                    <Setter.Value>
                                                        <RotateTransform Angle="-90" />
                                                    </Setter.Value>
                                                </Setter>
                                                <Setter TargetName="PART_Track" Property="Orientation" Value="Vertical" />
                                                <Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat" />
                                                <Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat" />
                                                <Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown" />
                                                <Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp" />
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ScrollViewer.Resources>
                    <ScrollViewer.Style>
                        <Style TargetType="{x:Type ScrollViewer}">
                            <Setter Property="Focusable" Value="false" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                        <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*" />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                            <DockPanel Margin="{TemplateBinding Padding}">
                                                <ScrollViewer Focusable="false" DockPanel.Dock="Top" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                                    <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,0,2,0" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}" />

                                                </ScrollViewer>
                                                <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local" />
                                            </DockPanel>
                                            <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                            <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                                            <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                                                <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left" />
                                                <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top" />
                                            </DockPanel>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ScrollViewer.Style>
                    
                    <ItemsControl ItemsSource="{Binding TeamMembersIncludingUnassigned}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                            	<StackPanel>
                            		<i:Interaction.Behaviors>
                            			<il:FluidMoveBehavior Duration="0:0:4" AppliesTo="Children" />
                            		</i:Interaction.Behaviors>
                            	</StackPanel>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemContainerStyle>
                            <Style TargetType="FrameworkElement">
                                <Setter Property="Margin" Value="6,6,0,0"/>
                            </Style>
                        </ItemsControl.ItemContainerStyle>
                    </ItemsControl>
                </ScrollViewer>
            </Grid>
        </ScrollViewer>
    </DataTemplate>
</ResourceDictionary>